home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '90 / MacHack 90 Contest Entries / Surovell Stuffƒ / GeeWhizƒ / PixMapFileIO.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-15  |  15.6 KB  |  642 lines  |  [TEXT/KAHL]

  1. /*
  2.     Copyright © 1988,1989,1990 by Succinct Systems
  3.  
  4.     433 Huronview
  5.     Ann Arbor, MI 48103
  6.     (313) 663-4903
  7.  
  8.     File:         PixMapFileIO.c
  9.     Model:         THINK C 4.0, MPW C 3.0
  10.  
  11.     ABSTRACT:
  12.         PICT file i/o routines, QuickDraw-32 compatible
  13.  
  14.     NOTES:
  15.         saving 32-bit PixMaps requires a lot of temporary heap space for CopyBits
  16.         calls; if your application saves empty (all black) pictures, increase
  17.         the partition size!
  18.  
  19.     KNOWN BUGS:
  20.         The routines which derive pictures from 16 and 32 bit deep PixMaps
  21.         dither them: beauty at the expense of functionality!
  22.  
  23.     HISTORY:
  24.         DAS 08-Jun-89    created this file    (David A. Surovell)
  25.         DAS 26-Oct-89    added “rect of interest” control
  26.         DAS 21-Apr-90    cleanly separated PICT <--> PixMap and PICT i/o operations
  27.                         added MacPaint B&W file reading
  28.         DAS 27-May-90    added new high-level I/O call discipline
  29.         DAS 08-Jun-90    collected file system arguments into single structure argument
  30. */
  31.  
  32. #include <StdMacIncludes.h>                /* include standard Mac headers */
  33. #include <Compatibility.h>                /* define compatibility control structures */
  34. #include "PixMapFileIO.h"
  35.  
  36.  
  37. OSErr Open_pixel_file(
  38.     PixMapHandle    thePixels,            /* destination of picture drawing */
  39.     Point            *pmBounds,            /* returned picture dimensions */
  40.     FSInfoRec        *fileSysData )        /* file system info */
  41. {
  42. GDHandle    savedGDevice;
  43. SFTypeList    theTypeList;
  44. WindowPtr    theDocWindow;
  45. SFReply        userReply;
  46. Point        sfOrigin;
  47. OSErr        errStat;
  48. long        newDirID, procID;
  49. short        newVolRefNum, oldRefNum;
  50.  
  51.     if ((fileSysData == NULL) || (fileSysData == NULL))
  52.         return (OSErr)(-1);
  53.  
  54.     SetPt( &sfOrigin, 80, 30 );
  55.     theTypeList[0] = 'PICT';
  56.     InitCursor();
  57.  
  58.     /* get filename and vRefNum from Standard File dialog box */
  59.     savedGDevice = GetGDevice();
  60.     SetGDevice( GetMainDevice() );
  61.     SFGetFile( sfOrigin, "\p", NULL, 1, theTypeList, NULL, &userReply );
  62.     SetGDevice( savedGDevice );
  63.     if (userReply.good)
  64.     {
  65.         errStat = GetWDInfo(
  66.             userReply.vRefNum, &newVolRefNum, &newDirID, &procID );
  67.  
  68.         if (errStat == noErr)
  69.         {
  70.             SetCursor( *GetCursor( watchCursor ) );
  71.             fileSysData->volumeID = newVolRefNum;
  72.             fileSysData->dirID = newDirID;
  73.             BlockMove(
  74.                 &(userReply.fName[0]), fileSysData->fileName,
  75.                 (unsigned long)(userReply.fName[0] + 1) );
  76.             errStat = Read_pixel_file( thePixels, pmBounds, fileSysData );
  77.         }
  78.     }
  79.     else
  80.         errStat = abortErr;
  81.  
  82.     InitCursor();
  83.     return errStat;
  84. }
  85.  
  86.  
  87. OSErr Read_pixel_file(
  88.     PixMapHandle    thePixels,            /* destination of picture drawing */
  89.     Point            *pmBounds,            /* returned picture dimensions */
  90.     FSInfoRec        *fileSysData )        /* file system info */
  91. {
  92. CGrafPtr        aGrafPort;
  93. CGrafPort        aGrafPortStorage;
  94. GrafPtr            savedPort;
  95. PixMapHandle    savedPixels;
  96. PicHandle        thePictHdl;
  97. Ptr                thePictInfo;
  98. Rect            pictFrame;
  99. OSErr            errStat;
  100. short            theFileRefNum;
  101.  
  102.     if ((thePixels == NULL) || (fileSysData == NULL))
  103.         return (OSErr)(-1);
  104.  
  105.     /* read the PICT file */
  106.     errStat = Read_pict_file( &thePictHdl, fileSysData );
  107.  
  108.     /* draw picture onto the PixMap */
  109.     if (errStat == noErr)
  110.     {
  111.         pictFrame = (**thePictHdl).picFrame;            /* get picture frame */
  112.         OffsetRect( &pictFrame, -pictFrame.left, -pictFrame.top );
  113.         if (pmBounds != NULL)
  114.             SetPt( pmBounds, pictFrame.right, pictFrame.bottom );
  115.  
  116.         if ((errStat == noErr) && !EmptyRect( &pictFrame ))
  117.         {
  118.             GetPort( &savedPort );
  119.  
  120.             OpenCPort( &aGrafPortStorage );
  121.             aGrafPort = &aGrafPortStorage;
  122.             SetPort( aGrafPort );
  123.             savedPixels = aGrafPort->portPixMap;
  124.             SetPortPix( thePixels );
  125.  
  126.             ClipRect( &((**thePixels).bounds) );    /* open clip to area of PixMap */
  127.  
  128.             DrawPicture( thePictHdl, &pictFrame );    /* draw pict off-screen */
  129.  
  130.             KillPicture( thePictHdl );                /* pitch picture */
  131.             SetPortPix( savedPixels );
  132.             CloseCPort( aGrafPort );
  133.             SetPort( savedPort );
  134.         }
  135.     }
  136.  
  137.     return errStat;
  138. }
  139.  
  140.  
  141. /*
  142. **    save a PixMap as a PICT file, using SFPutFile.
  143. */
  144. OSErr Save_pixel_file(
  145.     PixMapHandle    thePixels,            /* source pixels */
  146.     Rect            *rectOfInterest,    /* subset of pixmap to save */
  147.     FSInfoRec        *fileSysData )        /* file system info */
  148. {
  149. GDHandle    savedGDevice;
  150. SFTypeList    typeList;
  151. SFReply        userReply;
  152. Point        sfOrigin;
  153. long        newDirID, procID;
  154. short        newVolRefNum;
  155. OSErr        errStat;
  156.  
  157.     if ((thePixels == NULL) || (fileSysData == NULL))
  158.         return (OSErr)(-1);
  159.  
  160.     savedGDevice = GetGDevice();
  161.     SetGDevice( GetMainDevice() );
  162.     SetPt( &sfOrigin, 80, 30 );
  163.     SFPutFile(
  164.         sfOrigin, "\pSave Pixel File As:",
  165.         fileSysData->fileName, NULL, &userReply );
  166.  
  167.     SetGDevice( savedGDevice );
  168.  
  169.     if (userReply.good)
  170.     {
  171.         errStat = GetWDInfo(
  172.             userReply.vRefNum, &newVolRefNum, &newDirID, &procID );
  173.  
  174.         if (errStat == noErr)
  175.             errStat = HCreate(
  176.                 newVolRefNum, newDirID, userReply.fName, 'vell', 'PICT' );
  177.  
  178.         if ((errStat == noErr) || (errStat == dupFNErr))
  179.         {
  180.             /* copy fileName and volume refnum */
  181.             fileSysData->volumeID = newVolRefNum;
  182.             fileSysData->dirID = newDirID;
  183.             BlockMove(
  184.                 &(userReply.fName[0]), fileSysData->fileName,
  185.                 (unsigned long)(userReply.fName[0] + 1) );
  186.  
  187.             errStat = Write_pixel_file(
  188.                 thePixels, rectOfInterest, fileSysData );
  189.         }
  190.     }
  191.     else
  192.         errStat = abortErr;
  193.  
  194.     return errStat;
  195. }
  196.  
  197.  
  198. /*
  199. **    write a PixMap out as a PICT file.
  200. */
  201. OSErr Write_pixel_file(
  202.     PixMapHandle    thePixels,            /* source pixels */
  203.     Rect            *rectOfInterest,    /* subset of pixmap to save */
  204.     FSInfoRec        *fileSysData )        /* file system info */
  205. {
  206. PicHandle    thePictHdl;
  207. OSErr        errStat;
  208.  
  209.     if ((thePixels == NULL) || (fileSysData == NULL))
  210.         return (OSErr)(-1);
  211.  
  212.     SetCursor( *GetCursor( watchCursor ) );
  213.  
  214.     /* create picture, by copying the PixMap onto itself in strips */
  215.     thePictHdl = PixMap_CreatePict( thePixels, rectOfInterest );
  216.     if (thePictHdl == NULL)
  217.         errStat = Write_pict_file( thePictHdl, fileSysData );
  218.     else
  219.         errStat = (OSErr)(-1);
  220.  
  221.     /* finished with PICT, so pitch it */
  222.     if (thePictHdl != NULL)
  223.         KillPicture( thePictHdl );
  224.  
  225.     InitCursor();
  226.  
  227.     return errStat;
  228. }
  229.  
  230.  
  231. OSErr Save_GDevice_pixels(
  232.     GDHandle    targetGD,            /* contains source pixmap to save */
  233.     Rect        *rectOfInterest,    /* subset of pixmap to save */
  234.     FSInfoRec    *fileSysData )        /* file system info */
  235. {
  236. GDHandle    savedGDevice;
  237. PicHandle    thePictHdl;
  238. SFReply        userReply;
  239. Point        sfOrigin;
  240. long        newDirID, procID;
  241. short        newVolRefNum;
  242. OSErr        errStat = noErr;
  243.  
  244.     if ((targetGD == NULL) || (fileSysData == NULL))
  245.         return (OSErr)(-1);
  246.  
  247.     SetPt( &sfOrigin, 80, 30 );
  248.     savedGDevice = GetGDevice();
  249.  
  250.     SetGDevice( targetGD );
  251.     thePictHdl = PixMap_CreatePict( (**targetGD).gdPMap, rectOfInterest );
  252.     if (thePictHdl == NULL)
  253.     {
  254.         SetGDevice( savedGDevice );
  255.         return (OSErr)(-1);
  256.     }
  257.  
  258.     SetGDevice( GetMainDevice() );
  259.     InitCursor();
  260.     SFPutFile( sfOrigin, "\pSave As…", fileSysData->fileName, NULL, &userReply );
  261.     if (userReply.good)
  262.     {
  263.         errStat =
  264.             GetWDInfo( userReply.vRefNum, &newVolRefNum, &newDirID, &procID );
  265.  
  266.         if (errStat == noErr)
  267.         {
  268.             fileSysData->volumeID = newVolRefNum;
  269.             fileSysData->dirID = newDirID;
  270.             BlockMove(
  271.                 userReply.fName, fileSysData->fileName,
  272.                 (unsigned long)(userReply.fName[0] + 1) );
  273.  
  274.             errStat = Write_pict_file( thePictHdl, fileSysData );
  275.         }
  276.     }
  277.     else
  278.         errStat = abortErr;
  279.  
  280.     KillPicture( thePictHdl );
  281.     SetGDevice( savedGDevice );
  282.  
  283.     return errStat;
  284. }
  285.  
  286.  
  287. OSErr Read_pict_file(
  288.     PicHandle    *thePictHdl,        /* returned picture, read from file */
  289.     FSInfoRec    *fileSysData )        /* file system info */
  290. {
  291. Ptr        thePictInfo;
  292. Rect    pictFrame;
  293. OSErr    errStat, closeErrStat;
  294. long    pictBytes;
  295.  
  296.     if ((thePictHdl == NULL) || (fileSysData == NULL))
  297.         return (OSErr)(-1);
  298.  
  299.     /* open disk file */
  300.     errStat = HOpen(
  301.         fileSysData->volumeID, fileSysData->dirID,
  302.         fileSysData->fileName, fsRdPerm, &(fileSysData->fileRefNum) );
  303.     if ((fileSysData->fileRefNum < 0) && (errStat == noErr))
  304.         errStat = (OSErr)(-1);
  305.  
  306.     if (errStat == noErr)
  307.     {
  308.         /* find PICT data length, subtracting off the header */
  309.         /* size from the file size itself */
  310.         errStat = GetEOF( fileSysData->fileRefNum, &pictBytes );
  311.         pictBytes -= PICTIO_headersize;
  312.         if (pictBytes <= 0)
  313.             errStat = eofErr;
  314.  
  315.         if (errStat == noErr)
  316.             errStat = SetFPos(
  317.                 fileSysData->fileRefNum, fsFromStart, (long)PICTIO_headersize );
  318.  
  319.         /* skip over header */
  320.         if (errStat == noErr)
  321.         {
  322.             *thePictHdl = (PicHandle)NewHandle( pictBytes );
  323.             errStat = MemError();
  324.         }
  325.  
  326.         /* read actual picture data */
  327.         if (errStat == noErr)
  328.         {
  329.             HLock( (Handle)(*thePictHdl) );
  330.             thePictInfo = (Ptr)StripAddress( **thePictHdl );
  331.             errStat = FSRead( fileSysData->fileRefNum, &pictBytes, (Ptr)thePictInfo );
  332.             HUnlock( (Handle)(*thePictHdl) );
  333.         }
  334.  
  335.         if (fileSysData->fileRefNum > 0)
  336.         {
  337.             /* always close the opened file */
  338.             closeErrStat = FSClose( fileSysData->fileRefNum );
  339.             fileSysData->fileRefNum = (-1);
  340.     
  341.             /* preserve any previously reported errors */
  342.             if (errStat == noErr)
  343.                 errStat = closeErrStat;
  344.         }
  345.     }
  346.  
  347.     return errStat;
  348. }
  349.  
  350.  
  351. OSErr Write_pict_file(
  352.     PicHandle    thePictHdl,            /* picture to save */
  353.     FSInfoRec    *fileSysData )        /* file system info */
  354. {
  355. MacDrawFHeader    *theFHead;
  356. Ptr                thePictInfo;
  357. Rect            docRect, stripRect;
  358. OSErr            errStat = noErr, closeErrStat;
  359. long            headerBytes, pictBytes;
  360. short            imageWidth, imageHeight;
  361. short            copyStripCount, i;
  362.  
  363.     if ((thePictHdl == NULL) || (fileSysData == NULL))
  364.         return (OSErr)(-1);
  365.     else if (EmptyRect( &((**thePictHdl).picFrame) ))
  366.         return (OSErr)(-1);
  367.  
  368.     pictBytes = GetHandleSize( (Handle)thePictHdl );
  369.     if (pictBytes <= 0L)
  370.         return (OSErr)(-1);
  371.  
  372.     /* create new or open existing disk file */
  373.     errStat = HCreate(
  374.         fileSysData->volumeID, fileSysData->dirID,
  375.         fileSysData->fileName, 'vell', 'PICT' );
  376.     if ((errStat == noErr) || (errStat == dupFNErr))
  377.         errStat = HOpen(
  378.             fileSysData->volumeID, fileSysData->dirID,
  379.             fileSysData->fileName, fsRdWrPerm, &(fileSysData->fileRefNum) );
  380.  
  381.     /* write MacDraw-specific file header */
  382.     if ((errStat == noErr) && (fileSysData->fileRefNum > 0))
  383.     {
  384.         headerBytes = PICTIO_headersize;
  385.         theFHead = (MacDrawFHeader*)NewPtrClear( headerBytes );
  386.         errStat = MemError();
  387.         if (errStat == noErr)
  388.         {
  389.             theFHead->fType = 'DRWG';                /* init MacDraw header info */
  390.             theFHead->hdrID ='MD';                    /* ASCII 'MD' for MacDraw */
  391.             theFHead->version = 0;
  392.         }
  393.         else
  394.             theFHead = NULL;
  395.  
  396.         /* write file header */
  397.         if (errStat == noErr)
  398.             errStat = FSWrite( fileSysData->fileRefNum, &headerBytes, theFHead );
  399.  
  400.         /* dispose of file header buffer */
  401.         if (theFHead != NULL)
  402.             DisposPtr( theFHead );
  403.     }
  404.  
  405.     /* write PICT data */
  406.     if (errStat == noErr)
  407.     {
  408.         HLock( thePictHdl );
  409.         thePictInfo = (Ptr)StripAddress( *thePictHdl );
  410.         errStat = FSWrite( fileSysData->fileRefNum, &pictBytes, thePictInfo );
  411.         HUnlock( thePictHdl );
  412.  
  413.         if (errStat == noErr)
  414.             SetEOF( fileSysData->fileRefNum, (long)(pictBytes + headerBytes) );
  415.     }
  416.  
  417.     /* complicated cleanup begins… */
  418.     if (fileSysData->fileRefNum > 0)
  419.     {
  420.         /* always close the opened file, and update volume directory now! */
  421.         closeErrStat = FSClose( fileSysData->fileRefNum );
  422.         fileSysData->fileRefNum = (-1);
  423.         closeErrStat |= FlushVol( NULL, fileSysData->volumeID );
  424.  
  425.         /* preserve any previously reported errors */
  426.         if (errStat == noErr)
  427.             errStat = closeErrStat;
  428.     }
  429.  
  430.     return errStat;
  431. }
  432.  
  433.  
  434. OSErr Read_paint_file(
  435.     BitMap        *theBits,
  436.     FSInfoRec    *fileSysData )        /* file system info */
  437. {
  438. GrafPtr        savedPort;
  439. Ptr            sourceBuff, sourcePtr, destPtr;
  440. Ptr            thePictInfo;
  441. OSErr        errStat, closeErrStat;
  442. long        paintBytes;
  443. short        i;
  444.  
  445.     if ((theBits == NULL) || (fileSysData == NULL))
  446.         return (OSErr)(-1);
  447.  
  448.     sourceBuff = NewPtr( PAINTIO_blocksize );
  449.     errStat = MemError();
  450.     if (errStat != noErr)
  451.         return errStat;
  452.  
  453.     SetRect( &(theBits->bounds), 0, 0, PAINTIO_width, PAINTIO_height );
  454.     theBits->rowBytes = PAINTIO_rowbytes;
  455.     theBits->baseAddr = NewPtr( PAINTIO_width * PAINTIO_height / 8L );
  456.     errStat = MemError();
  457.     if (errStat != noErr)
  458.     {
  459.         DisposPtr( sourceBuff );
  460.         return errStat;
  461.     }
  462.  
  463.     /* open disk file */
  464.     errStat = HOpen(
  465.         fileSysData->volumeID, fileSysData->dirID,
  466.         fileSysData->fileName, fsRdPerm, &(fileSysData->fileRefNum) );
  467.     if ((fileSysData->fileRefNum < 0) && (errStat == noErr))
  468.         errStat = (OSErr)(-1);
  469.  
  470.     if (errStat == noErr)
  471.     {
  472.         /* find PICT data length, subtracting off the header */
  473.         /* size from the file size itself */
  474.         errStat = GetEOF( fileSysData->fileRefNum, &paintBytes );
  475.         paintBytes -= PICTIO_headersize;
  476.         if (paintBytes <= 0)
  477.             errStat = eofErr;
  478.  
  479.         if (errStat == noErr)
  480.             errStat = SetFPos(
  481.                 fileSysData->fileRefNum, fsFromStart, (long)PAINTIO_headersize );
  482.  
  483.         destPtr = theBits->baseAddr;
  484.         for (i=0; (i<PAINTIO_height) && (errStat == noErr); i++) 
  485.         {
  486.             /* unpack 72 bytes worth of BitMap pixels */
  487.             sourcePtr = sourceBuff;
  488.             UnpackBits( &sourcePtr, &destPtr, PAINTIO_rowbytes );
  489.  
  490.             /* read the next piece of Paint file into local buffer */
  491.             paintBytes = PAINTIO_blocksize;
  492.             errStat = FSRead( fileSysData->fileRefNum, &paintBytes, sourceBuff );        
  493.  
  494.             if ((errStat == eofErr) && (paintBytes >= 0))
  495.                 errStat = noErr;
  496.         }
  497.  
  498.         if (fileSysData->fileRefNum > 0)
  499.         {
  500.             /* always close the opened file */
  501.             closeErrStat = FSClose( fileSysData->fileRefNum );
  502.             fileSysData->fileRefNum = (-1);
  503.  
  504.             /* preserve any previously reported errors */
  505.             if (errStat == noErr)
  506.                 errStat = closeErrStat;
  507.         }
  508.     }
  509.  
  510.     if (sourceBuff != NULL)
  511.         DisposPtr( sourceBuff );
  512.  
  513.     return errStat;
  514. }
  515.  
  516.  
  517. /*
  518. **    create a QuickDraw picture from a PixMap
  519. */
  520. PicHandle PixMap_CreatePict(
  521.     PixMapHandle    thePixels,
  522.     Rect            *rectOfInterest )
  523. {
  524. GrafPtr            savedPort;
  525. CGrafPtr        aGrafPort;
  526. CGrafPort        aGrafPortStorage;
  527. PixMapHandle    savedPixels;
  528. PicHandle        newPic;
  529. OSErr            errStat = noErr;
  530. Rect            picRect, stripRect;
  531. Ptr                thePixInfo;
  532. short            copyStripCount, stripHeight, theTransferMode, i;
  533.  
  534.     if (thePixels == NULL)
  535.         return NULL;
  536.     else if ((**thePixels).baseAddr == NULL)
  537.         return NULL;
  538.  
  539.     if (rectOfInterest != NULL)
  540.         picRect = *rectOfInterest;
  541.     else
  542.     {
  543.         picRect = (**thePixels).bounds;
  544.         OffsetRect( &picRect, -picRect.left, -picRect.top );
  545.     }
  546.  
  547.     if (EmptyRect( &picRect ))
  548.         return NULL;
  549.  
  550.     GetPort( &savedPort );
  551.     OpenCPort( &aGrafPortStorage );
  552.     aGrafPort = &aGrafPortStorage;
  553.     SetPort( aGrafPort );
  554.     SetPort( aGrafPort );
  555.     savedPixels = aGrafPort->portPixMap;    /* save the current PixMap, to be disposed of later */
  556.     SetPortPix( thePixels );                /* install the target PixMap */
  557.  
  558.     /* keep the size of the copy down to a “reasonable” amount */
  559.     copyStripCount =
  560.         ((long)(picRect.right - picRect.left) * (long)(picRect.bottom - picRect.top))
  561.         / (256L * 64L);
  562.     if ((**thePixels).pixelSize > 8)
  563.         copyStripCount *= 8;
  564.  
  565.     if (copyStripCount < 1)
  566.         copyStripCount = 1;
  567.     else if (copyStripCount > (picRect.bottom - picRect.top))
  568.         copyStripCount = (picRect.bottom - picRect.top);
  569.  
  570.     stripHeight = picRect.bottom / copyStripCount;
  571.     stripRect = picRect;
  572.     stripRect.bottom = stripHeight;
  573.  
  574.     /* optionally dither 32-bit PixMaps */
  575.     theTransferMode = ((**thePixels).pixelSize > 8) ? srcCopy | (short)64 : srcCopy;
  576.  
  577.     HLock( thePixels );
  578.     thePixInfo = (Ptr)StripAddress( *thePixels );
  579.  
  580.     /* clip the drawing sensibly, and copy PixMap onto itself in strips */
  581.     ClipRect( &picRect );
  582.     newPic = OpenPicture( &picRect );
  583.         for (i=0; (i<=copyStripCount) && (errStat == noErr); i++)
  584.         {
  585.             CopyBits(
  586.                 thePixInfo, thePixInfo,
  587.                 &stripRect, &stripRect, theTransferMode, NULL );
  588.  
  589.             errStat = (OSErr)QDError();        /* check for lack o’ stack! */
  590.  
  591.             OffsetRect( &stripRect, 0, stripHeight );
  592.             if (stripRect.bottom > picRect.bottom)
  593.                 stripRect.bottom = picRect.bottom;
  594.         }
  595.     ClosePicture();
  596.  
  597.     HUnlock( thePixels );
  598.  
  599.     /* if QuickDraw reported an error, then the picture it created is */
  600.     /* probably empty, so pitch it */
  601.     if (errStat != noErr)
  602.     {
  603.         KillPicture( newPic );
  604.         newPic = NULL;
  605.     }
  606.  
  607.     SetPortPix( savedPixels );        /* install the original PixMap */
  608.     CloseCPort( aGrafPort );        /* pitch port stuff */
  609.     SetPort( savedPort );
  610.  
  611.     return newPic;
  612. }
  613.  
  614.  
  615. void FSInfo_Init(
  616.     FSInfoRec    *fileSysData )
  617. {
  618.     if (fileSysData == NULL)
  619.         RETURN;
  620.  
  621.     fileSysData->dirID = (-1L);
  622.     fileSysData->volumeID = (-1);
  623.     fileSysData->fileRefNum = (-1);
  624.     fileSysData->fileName[0] = '\0';
  625. }
  626.  
  627.  
  628. Boolean FSInfo_Valid(
  629.     FSInfoRec    *fileSysData )
  630. {
  631.     if (fileSysData == NULL)
  632.         return FALSE;
  633.  
  634.     return (Boolean)
  635.         ((fileSysData->dirID > 0L) &&
  636.         (fileSysData->volumeID >= 1) &&
  637.         (fileSysData->fileName[0] != '\0'));
  638. }
  639.  
  640.  
  641.  
  642.